// ANES24PubOp
log using ANES24PubOp.log, replace

use "C:\Users\sbstjp\OneDrive - Cardiff University\anes_timeseries_2024_stata_20250219.dta" // ANES 2024 Time Series Study // Preliminary Release: Pre-Election Data February 19, 2025 version

* Rename variables
rename V241290x Edi 
rename V241372x Tgbathroom 
rename V241375x Tgsport 
rename V241412x Appprotestgaza

* Drop missing values
foreach var in Edi Tgbathroom Tgsport Appprotestgaza {
    replace `var' = . if `var' ==-1
    tabulate `var', missing
}

// Demographics
*Delete missing values and rename
rename V241458x age
replace age=. if age<0 

replace V241177=. if V241177==99 
replace V241177=. if V241177<0
rename V241177 libconsp

* Generate dummies
gen FemaleGender=.
replace FemaleGender=1 if V241551==1
replace FemaleGender=2 if V241551==2

gen Graduate=.
replace Graduate=0 if inrange(V241465x, 1, 3)
replace Graduate=1 if inlist(V241465x, 4, 5)

gen BIPOC=.
replace BIPOC=0 if V241501x==1
replace BIPOC=1 if inrange(V241501x, 2, 6)

// Analysis
tab Edi [aweight=V240105a]
tab Edi if libconsp<4 [aweight=V240105a]
tab Edi if libconsp>4 [aweight=V240105a]
tab Edi if FemaleGender==1 [aweight=V240105a]
tab Edi if FemaleGender==2 [aweight=V240105a]
tab Edi if Graduate==0 [aweight=V240105a]
tab Edi if Graduate==1 [aweight=V240105a]
tab Edi if BIPOC==0 [aweight=V240105a]
tab Edi if BIPOC==1 [aweight=V240105a]
tab Edi if age<35 [aweight=V240105a]
tab Edi if age>=35 & age<=59 [aweight=V240105a]
tab Edi if age>59 [aweight=V240105a]

tab Tgbathroom [aweight=V240105a]
tab Tgbathroom if libconsp<4 [aweight=V240105a]
tab Tgbathroom if libconsp>4 [aweight=V240105a]
tab Tgbathroom if FemaleGender==1 [aweight=V240105a]
tab Tgbathroom if FemaleGender==2 [aweight=V240105a]
tab Tgbathroom if Graduate==0 [aweight=V240105a]
tab Tgbathroom if Graduate==1 [aweight=V240105a]
tab Tgbathroom if BIPOC==0 [aweight=V240105a]
tab Tgbathroom if BIPOC==1 [aweight=V240105a]
tab Tgbathroom if age<35 [aweight=V240105a]
tab Tgbathroom if age>=35 & age<=59 [aweight=V240105a]
tab Tgbathroom if age>59 [aweight=V240105a]

tab Tgsport [aweight=V240105a]
tab Tgsport if libconsp<4 [aweight=V240105a]
tab Tgsport if libconsp>4 [aweight=V240105a]
tab Tgsport if FemaleGender==1 [aweight=V240105a]
tab Tgsport if FemaleGender==2 [aweight=V240105a]
tab Tgsport if Graduate==0 [aweight=V240105a]
tab Tgsport if Graduate==1 [aweight=V240105a]
tab Tgsport if BIPOC==0 [aweight=V240105a]
tab Tgsport if BIPOC==1 [aweight=V240105a]
tab Tgsport if age<35 [aweight=V240105a]
tab Tgsport if age>=35 & age<=59 [aweight=V240105a]
tab Tgsport if age>59 [aweight=V240105a]

tab Appprotestgaza [aweight=V240105a]
tab Appprotestgaza if libconsp<4 [aweight=V240105a]
tab Appprotestgaza if libconsp>4 [aweight=V240105a]
tab Appprotestgaza if FemaleGender==1 [aweight=V240105a]
tab Appprotestgaza if FemaleGender==2 [aweight=V240105a]
tab Appprotestgaza if Graduate==0 [aweight=V240105a]
tab Appprotestgaza if Graduate==1 [aweight=V240105a]
tab Appprotestgaza if BIPOC==0 [aweight=V240105a]
tab Appprotestgaza if BIPOC==1 [aweight=V240105a]
tab Appprotestgaza if age<35 [aweight=V240105a]
tab Appprotestgaza if age>=35 & age<=59 [aweight=V240105a]
tab Appprotestgaza if age>59 [aweight=V240105a]

log close